package net.sx.minemodule.mvp.bean;

/**
 * Created by 拇指 on 2019/7/4 0004.
 * Email:muzhi@uoko.com
 * update 20190724 long.tu
 */
public class EnumSchedule {

    //    10->等待平台处理售后是否有效;
//    11-> 平台同意该售后订单并移交状态至 (3|7 根据return_type字段区分);
//    -11-> 平台拒绝该售后订单并结束售后订单流程;
//    3->等待消费者上传物流信息;
//    4->等待供应商确定收货;
//    5->供应商确定收货成功 下面可选状态:(6|-6);
//    6 ->供应商同意用户退货请求 (流转至处理人:2 状态可选:20|-20);
//    -6->供应商拒绝用户退货请求;
//    7->供应商等待确定退款;
//    8->供应商同意退款(下一步状态:20|-20);
//    -8->供应商拒绝退款(结束流程);
//    20->平台同意退货(退款);
//    -20->平台拒绝退货(退款);
//
    public static final EnumSchedule REFUND_REQUEST = new EnumSchedule(0, "申请退款", "提交申请");
    public static final EnumSchedule RETURN_GOODS_REQUEST = new EnumSchedule(1, "申请退款退货", "提交申请");
    public static final EnumSchedule GOODS_REQUEST = new EnumSchedule(2, "申请退货", "提交申请");
    public static final EnumSchedule WAITING_REQUEST_10 = new EnumSchedule(10, "等待卖家处理", "卖家审核");
        public static final EnumSchedule WAITING_REQUEST_11 = new EnumSchedule(11, "等待卖家处理", "卖家审核");
        public static final EnumSchedule REJECT_REQUEST = new EnumSchedule(-11, "申请已驳回", "已完成");
    //退款退货流程 11状态分支
    public static final EnumSchedule RETURN_GOODS_WAIT_RECEIVE = new EnumSchedule(3, "等待买家退货", "卖家审核");
    public static final EnumSchedule RETURN_GOODS_WAIT_CHECK = new EnumSchedule(4, "等待卖家验货", "卖家审核");
    public static final EnumSchedule RETURN_GOODS_WAIT_REFUND_5 = new EnumSchedule(5, "等待退款中", "卖家收到商品");
        public static final EnumSchedule RETURN_GOODS_WAIT_REFUND_6 = new EnumSchedule(6, "等待退款中", "卖家收到商品");
            public static final EnumSchedule RETURN_GOODS_SUCCESS = new EnumSchedule(20, "退款退货成功", "已完成");
            public static final EnumSchedule RETURN_GOODS_REJECT_20 = new EnumSchedule(-20, "申请已驳回", "已完成");
        public static final EnumSchedule RETURN_GOODS_REJECT_6 = new EnumSchedule(-6, "申请已驳回", "已完成");
    //退款流程 11状态分支
    public static final EnumSchedule REFUND_WAIT = new EnumSchedule(7, "等待卖家处理", "卖家审核");
    public static final EnumSchedule REFUND_VERIFY_FINISH = new EnumSchedule(8, "商家审核完成", "卖家审核");
        public static final EnumSchedule REFUND_SUCCESS = new EnumSchedule(20, "退款成功", "已完成");
        public static final EnumSchedule REFUND_REJECT_20 = new EnumSchedule(-20, "申请已驳回", "已完成");
    public static final EnumSchedule REFUND_REJECT_8 = new EnumSchedule(-8, "申请已驳回", "已完成");

    public static final EnumSchedule REQUEST_CANCEL = new EnumSchedule(-1, "客户撤销申请", "已完成");
    public static final EnumSchedule WAITING_REQUEST = new EnumSchedule(0, "待申请", "待申请");


    //一般不会有这个状态
//    public static final EnumSchedule WAITING_REQUEST = new EnumSchedule(0, "待申请", "待申请");
//    public static final EnumSchedule WAITING_VERIFY = new EnumSchedule(1, "卖家审核", "卖家审核");
//
//    public static final EnumSchedule REQUEST_VERIFY = new EnumSchedule(1, "申请退款", "申请退款");
//    public static final EnumSchedule WAITING_REFUND_MONEY = new EnumSchedule(2, "等待退款中", "等待退款中");
//    public static final EnumSchedule CANCEL = new EnumSchedule(3, "客户撤销申请", "已完成");
//    public static final EnumSchedule SALER_REFUSE = new EnumSchedule(4, "申请已驳回", "已完成");
//    public static final EnumSchedule COMPLETE = new EnumSchedule(5, "退款成功", "已完成");
//    /**
//     * 退货退款
//     */
//    public static final EnumSchedule GOODS_REQUEST_VERIFY = new EnumSchedule(1, "申请退款退货", "申请退款退货");
//    public static final EnumSchedule GOODS_WAITING_RESEND = new EnumSchedule(2, "等待买家退货", "等待买家退货");
//    public static final EnumSchedule GOODS_WAITING_RECEIVE = new EnumSchedule(3, "等待卖家收货", "等待卖家收货");
//    public static final EnumSchedule GOODS_RECEIVED = new EnumSchedule(4, "等待卖家验收", "等待卖家验收");
//    public static final EnumSchedule GOODS_WAITING_REFUND_MONEY = new EnumSchedule(5, "等待退款中", "等待退款中");
//    public static final EnumSchedule GOODS_CANCEL = new EnumSchedule(6, "客户撤销申请", "已完成");
//    public static final EnumSchedule GOODS_CREFUSE = new EnumSchedule(7, "申请已驳回", "已完成");
//    public static final EnumSchedule GOODS_COMPLETE = new EnumSchedule(8, "退款退货成功", "已完成");


    private final int key;
    private final String value; //显示在水平进度最右边
    private final String value2; //显示在水平进度item下面文字

    public static EnumSchedule getSchedule(int key, int type) {
        if (type == EnumRefundType.REFUND.getKey()) {
            //退款类型
            switch (key) {
                case 0:
                    return REFUND_REQUEST;
                case 1:
                    return RETURN_GOODS_REQUEST;
                case 2:
                    return GOODS_REQUEST;
                case 10:
                    return WAITING_REQUEST_10;
                case 11:
                    return WAITING_REQUEST_11;
                case -11:
                    return REJECT_REQUEST;
                case 7:
                    return REFUND_WAIT;
                case 8:
                    return REFUND_VERIFY_FINISH;
                case 20:
                    return REFUND_SUCCESS;
                case -20:
                    return REFUND_REJECT_20;
                case -8:
                    return REFUND_REJECT_8;
            }
        } else {
            //退款类型
            switch (key) {
                case 0:
                    return REFUND_REQUEST;
                case 1:
                    return RETURN_GOODS_REQUEST;
                case 2:
                    return GOODS_REQUEST;
                case 10:
                    return WAITING_REQUEST_10;
                case 11:
                    return WAITING_REQUEST_11;
                case -11:
                    return REJECT_REQUEST;
                case 3:
                    return RETURN_GOODS_WAIT_RECEIVE;
                case 4:
                    return RETURN_GOODS_WAIT_CHECK;
                case 5:
                    return RETURN_GOODS_WAIT_REFUND_5;
                case 6:
                    return RETURN_GOODS_WAIT_REFUND_6;
                case 20:
                    return RETURN_GOODS_SUCCESS;
                case -20:
                    return RETURN_GOODS_REJECT_20;
                case -6:
                    return RETURN_GOODS_REJECT_6;
            }
        }
        return WAITING_REQUEST;
    }

    /**
     * 根据int获取状态描述
     *
     * @param key  状态
     * @param type 类型，{@link EnumRefundType}
     * @return
     */
    public static String getScheduleName(int key, int type) {
        EnumSchedule schedule = getSchedule(key, type);
        if (schedule == null) {
            return "未知状态";
        } else {
            return schedule.value;
        }
    }

    /**
     * 也就显示进度 已申请-已审核-已完成，用这个
     */
    public static String getScheduleName2(int key, int type) {
        EnumSchedule schedule = getSchedule(key, type);
        if (schedule == null) {
            return "未知状态";
        } else {
            return schedule.value2;
        }
    }

    private EnumSchedule(int key, String value, String value2) {
        this.key = key;
        this.value = value;
        this.value2 = value2;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public String getValue2() {
        return value2;
    }
}
